$(function() {
	//绑定派单按钮的单击事件
	$("body").on("click","._paidan",function(){
		var paidanBtn = $(this);
		console.info(paidanBtn.prev().val());
		$.post(
				"/food/orderInfo/paidan.do",
				{"orderInfoId":paidanBtn.prev().val()},
				function(data){
					if(data.ok){
						toastr.success("派单成功");
						setTimeout(function(){
							window.location="/food/orderInfo/page-1.html";						     	
							},350);
					}else{
						toastr.error("派单失败："+data.message);
					}
				},"json"
			);
		return false;
	});
	
	let deleteDialog;//删除确认对话框
	let deleteBtn//删除按钮
	
	$.get(
			"food/order/orderManagedelete.html",
			function(html){
				deleteDialog = $(html).filter(".modal").appendTo("body");
				//处理删除按钮事件
				deleteDialog.find("._confirm").on("click",function(){
					deleteDialog.modal("hide");//隐藏模态框
					$.post(
							"/food/orderInfo/delete.do",
							{"orderInfoId":deleteBtn.prev().val()},
							function(data){
								if(data.ok){
									toastr.success("删除成功");
									setTimeout(function(){
										window.location="/food/orderInfo/page-1.html";						     	
										},350);
								}else{
									toastr.error("删除失败："+data.message);
								}
							},"json"
					);
					return false;
				});
			}
		);
	//绑定删除按钮的单击事件
	$("body").on("click","._delete",function(){
		deleteBtn = $(this);
		deleteDialog.modal("show");
		
		return false;
	});
	
	$("body").on("click","._update",function(){
		let updateBtn = $(this);
//		window.location="/food/orderInfo/update.do?foodOrderInfoId="+updateBtn.prev().val()+"&foodOrderInfoContent="+updateBtn.next().val();	
		window.location="/food/order/orderManageUpdate.jsp?foodOrderInfoId="+updateBtn.prev().val()+"&foodOrderInfoContent="+updateBtn.next().val();	
		return false;
	});
	
});